package com.eshop.modules.system.service.mapper;

import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.eshop.modules.system.domain.User;
import com.eshop.common.mapper.CoreMapper;

@Repository
public interface SysUserMapper extends CoreMapper<User>
{
    @Update({ "update `user` set password = #{password} , last_password_reset_time = #{lastPasswordResetTime} where username = #{username}" })
    void updatePass(@Param("password") final String password, @Param("lastPasswordResetTime") final String lastPasswordResetTime, @Param("username") final String username);
    
    @Update({ "update `user` set email = #{email} where username = #{username}" })
    void updateEmail(@Param("email") final String email, @Param("username") final String username);
    
    @Select({ "SELECT u.id,u.nick_name,u.sex,u.dept_id,u.enabled,u.create_time,u.phone,u.email,u.job_id ,u.`password` ,u.username,ua.real_name avatar FROM `user`  u LEFT JOIN user_avatar ua ON u.avatar_id = ua.id  WHERE u.username = #{username}" })
    User findByName(final String userName);
}
